package cn.edu.zafu.bigdata.zyf;

class InvalidScoreException extends Exception {
    public InvalidScoreException(String message) {
        super(message);
    }
}

public class ScoreValidation {

    // 静态方法checkScore，如果分数不在0到100之间则抛出InvalidScoreException
    public static void checkScore(int score) throws InvalidScoreException {
        if (score < 0 || score > 100) {
            throw new InvalidScoreException("Score must be between 0 and 100. Invalid score provided: " + score);
        }
        System.out.println("Score is valid: " + score);
    }

    public static void main(String[] args) {
        // 假设这是用户输入的分数
        int score = -10; // 测试分数无效的情况

        try {
            // 尝试调用checkScore方法
            checkScore(score);
        } catch (InvalidScoreException e) {
            // 捕获异常并输出提示信息
            System.out.println("Error: " + e.getMessage());
        }
    }
}